
include('shared.lua')

/*---------------------------------------------------------
   Name: DrawTranslucent
   Desc: Draw translucent
---------------------------------------------------------*/
function ENT:DrawTranslucent()
	self:DrawEntityOutline( 1.2 + math.sin( CurTime() * 60 ) * 0.05 )
	self:Draw()
end

function ENT:Draw()
	self:DrawModel()
end

function BankMachineMenu( um )
	local money = um:ReadLong()
	local isowner = um:ReadBool()
	local moneyinbm = um:ReadLong()
		
	local bmm = vgui.Create("DFrame")
    bmm:SetSize(ScrW()*0.3,ScrH()*0.6)
	bmm:Center()
    bmm:SetTitle("Bank machine menu")
    bmm:MakePopup()
	local Panel = vgui.Create("DPanelList")
	Panel:SetParent(bmm)
	Panel:SetPos(12,28)
	Panel:SetSize(ScrW()*0.3*0.95,ScrH()*0.6*0.89)
		local BankCat = vgui.Create("DCollapsibleCategory")
		BankCat:SetLabel("Client")
			local BankPanel = vgui.Create("DPanelList")
			BankPanel:SetSpacing(5)
			BankPanel:SetSize(ScrW()*0.3*0.95,ScrH()*0.6*0.89/2)
			BankPanel:EnableHorizontal(false)
			BankPanel:EnableVerticalScrollbar(true)
				
				local MoneyAtBank = vgui.Create("DLabel")
				MoneyAtBank:SetText("You have "..tostring(money)..CUR.." in your bank")
				BankPanel:AddItem(MoneyAtBank)

				local SaveMoneyButton = vgui.Create("DButton")
				SaveMoneyButton:SetText("Save money at bank")
				SaveMoneyButton.DoClick = function()
					Derma_StringRequest("Amount of money", "How much money do you want to save?", "", function(a) LocalPlayer():ConCommand("say /savemoney " .. tostring(a)) end)				
				end
				BankPanel:AddItem(SaveMoneyButton)
				
				local GetMoneyButton = vgui.Create("DButton")
				GetMoneyButton:SetText("Get money from bank")
				GetMoneyButton.DoClick = function()
					Derma_StringRequest("Amount of money", "How much money do you want to get?", "", function(a) LocalPlayer():ConCommand("say /getmoney " .. tostring(a)) end)				
				end
				BankPanel:AddItem(GetMoneyButton)
				
				local CheckMoneyButton = vgui.Create("DButton")
				CheckMoneyButton:SetText("Check money at bank")
				CheckMoneyButton.DoClick = function() LocalPlayer():ConCommand("say /checkmoney") end
				BankPanel:AddItem(CheckMoneyButton)
				
				local CheckTaxButton = vgui.Create("DButton")
				CheckTaxButton:SetText("Check taxes at bank")
				CheckTaxButton.DoClick = function() LocalPlayer():ConCommand("say /checktax") end
				BankPanel:AddItem(CheckTaxButton)
		if isowner then	
			local AdminCat = vgui.Create("DCollapsibleCategory")
			AdminCat:SetLabel("Cherman")
				local AdminPanel = vgui.Create("DPanelList")
				AdminPanel:SetSpacing(5)
				AdminPanel:SetSize(ScrW()*0.3*0.95,ScrH()*0.6*0.89/2)
				AdminPanel:EnableHorizontal(false)
				AdminPanel:EnableVerticalScrollbar(true)
				local MoneyAtMachine = vgui.Create("DLabel")
				MoneyAtMachine:SetText("Machine contains "..tostring(moneyinbm)..CUR)
				AdminPanel:AddItem(MoneyAtMachine)
				
					local OpenBankButton = vgui.Create("DButton")
					OpenBankButton:SetText("Open Bank")
					OpenBankButton.DoClick = function() LocalPlayer():ConCommand("say /openbankofbm") end
					AdminPanel:AddItem(OpenBankButton)
			
					local CloseBankButton = vgui.Create("DButton")
					CloseBankButton:SetText("Close Bank")
					CloseBankButton.DoClick = function() LocalPlayer():ConCommand("say /closebankofbm") end
					AdminPanel:AddItem(CloseBankButton)
			
					local ChangeTaxButton = vgui.Create("DButton")
					ChangeTaxButton:SetText("Change taxes")
					ChangeTaxButton.DoClick = function()
						Derma_StringRequest("Percent of taxes", "How much taxes you want?", "", function(a) LocalPlayer():ConCommand("say /taxofbm " .. tostring(a)) end)					
					end
					AdminPanel:AddItem(ChangeTaxButton)			
					
					local GetMoneyButton = vgui.Create("DButton")
					GetMoneyButton:SetText("Extract all money from machine")
					GetMoneyButton.DoClick = function() LocalPlayer():ConCommand("say /getmoneyofbm") end
					AdminPanel:AddItem(GetMoneyButton)	
					
					local MoveBM = vgui.Create("DButton")
					MoveBM:SetText("Move the bank machine")
					MoveBM.DoClick = function() LocalPlayer():ConCommand("say /getbm") end
					AdminPanel:AddItem(MoveBM)	
					
					local SellBM = vgui.Create("DButton")
					SellBM:SetText("Sell the bank machine")
					SellBM.DoClick = function() LocalPlayer():ConCommand("say /sellbm") end
					AdminPanel:AddItem(SellBM)	
					
				AdminCat:SetContents(AdminPanel)
			Panel:AddItem(AdminCat)
		end				
	BankCat:SetContents(BankPanel)	
	Panel:AddItem(BankCat)
end
usermessage.Hook("bankmachinemenu", BankMachineMenu)